<template>
	<view class="banshizhinan-page flex flex-column bgcolor1 m-h100">
		<view v-for="(item,index) in dataList" :key="index" class="border-bottom p-2 rounded flex  justify-between"
			@click="navTo(item)">
			<text class="fs-28 ftcolor1">{{item.title}}</text>
			<text class="icon-xiayibu iconfont ftcolor4 fs-28"></text>
		</view>
		<view class="text-center py-3" v-if="this.tempList.length === 15"><text class="fs-24 ftcolor2"
				@click="clickMore">查看更多</text></view>
		<noneBox v-if="dataList.length === 0"></noneBox>
	</view>
</template>

<script>
	import serviceApi from '@/api/serviceApi.js'
	export default {
		data() {
			return {
				dataList: [],
				tempList: [],
				page: 1,
			}
		},
		created() {
			uni.setNavigationBarTitle({
				title: this.$route.query.title
			});
			if(this.$route.query.title === '办事指南'){
				this.uni_bszn()
			} else{
				this.uni_njpxs()
			}
		},
		methods: {
			uni_bszn() {
				serviceApi.uni_bszn({
					page: this.page,
					limit: 15
				}).then(res => {
					this.tempList = res.data
					if (this.page === 1) {
						this.dataList = res.data
					} else {
						this.dataList = this.dataList.concat(res.data)
					}
				})
			},
			uni_njpxs() {
				serviceApi.uni_njpxs({
					page: this.page,
					limit: 15
				}).then(res => {
					this.tempList = res.data
					if (this.page === 1) {
						this.dataList = res.data
					} else {
						this.dataList = this.dataList.concat(res.data)
					}
				})
			},
			clickMore() {
				if (this.tempList.length === 15) {
					this.page++
					if(this.$route.query.title === '办事指南'){
						this.uni_bszn()
					} else{
						this.uni_njpxs()
					}
				}
			},
			navTo(item) {
				uni.setStorageSync('curservicedetails',item)
				uni.navigateTo({
					url: '/pages/service/details?title=' + this.$route.query.title
				})
			}
		}
	}
</script>

<style lang="scss">
	.banshizhinan-page {}
</style>